from pymongo import MongoClient
import pandas as pd
client = MongoClient(port=27017)
db=client['tiktok_p2']
import csv
# collist=db.list_collection_names()
# excluded=['feliznavidad','ramadanmubarak','horrotok','skatelife','worldseries','showupshowoff','happyhanukah','heinzhalloween','diwali','arabtiktok','lgbthistory','comingofage','stopasianhate','spookytreats','micellarrewind','cocinando' ]
# collist=list(set(collist)-set(excluded))

collist=['gaminglife', 'whatilearned', 'happyholi', 'stpatricksday', 'ontherunway', 'joblife', 'homecooked', 'tiktokcars', 'gettheretogether', 'zodiacsign', 'hellowinter', 'healthyheart', 'tiktokfood', 'petsontiktok', 'homecook', 'timewarpwaterfall', 'tiktokdiy', 'graphicdesign', 'holidaycrafts', 'foodtiktok', 'emophase', 'neontwin', 'tiktokwildlifeday', 'nflplayoffs', 'smallbusiness', 'needtoknow', 'superbowllv', 'mifamilia', 'nbaallstar', 'hyperfixated', 'couplethings', 'kissyourpet', 'greenscreenscan', 'tabletop', 'wildanimals', 'stemlife', 'easyrecipe', 'fallguysmoments', 'inkdrawing', 'gamenight', 'planttiktok', 'yellow', 'imaghost', 'mlkday', 'perfectmatch', 'homecafe', 'siblinggoals', 'whenwomenwin', 'promszn', 'halloweenlook', 'christmas2020', 'diyprojects', '2018vs2021', 'tiktokfashionmonth', 'theatrekids', 'mystyle', 'artmas', 'wrestlemania', 'cleaningtiktok', 'mypfp', 'holidaymusic', 'beautyhack', 'carsoftiktok', 'moneytok', 'homediy', 'holidaysourway', 'ratatouillemusical', 'happyhanukkah', 'colddays', 'thriftflip', 'carhacks', 'familyimpression', 'aprilfools', 'falldiy', 'recordsday', 'givingthanks', 'cartiktok', 'fallfashion', 'homeimprovement', 'crowdcheers', '2021affirmations', 'mobilegame', 'problemsolved', 'herstory', 'weirdpets', 'nbaisback', 'haventseen', 'baseballtiktok', 'ohno', 'clingypet', 'fantheory', 'coversforlovers', 'homemade', 'learnwithme', 'happyeaster', 'womeninstem', 'seashanty', 'somethingyoulearned', 'whenwewereyounger', 'vinylclub', 'productivity', 'animation', 'yearontiktok', 'coldweather', 'rareaesthetic', 'sidetable', 'onlinedating', 'puppybowl', 'perfectdrink', 'colorblast', 'sheesh', 'roomtour', 'thriftshop', 'sfxmakeup', 'housetour', 'perfectgifts', 'myrecommendation', 'nowruz', 'weekendvibes', 'givingszn', 'royalrumble', 'neonshadow', 'springvibes', 'learnontiktok', 'defrosting', 'doctorsoftiktok', 'healthycooking', 'dailyvlog', 'stylehacks', 'nhlfaceoff', 'ecohacks', 'catchphrases', 'wishlist', 'personalfinance', 'meditation101', 'diceroll', 'youwantmore', 'wordsofwisdom', 'upcycling', 'stepbystep', 'wip', 'baseballisback', 'welldone', 'onhold', 'unwrapthedeals', 'halloweenishere', 'notaperfectperson', 'typing', 'foodie', 'beautyhacks', 'inspirationalquotes', 'snowstorm', 'tipsandtricks', 'puppiesonly', 'fanedit', 'howbizarre', 'marchmadness', 'myhaul', 'meleaving', 'blackandproud', 'dayandnight', 'veteransday', 'fitnesslife', 'readysetshop', 'earthday', 'valentinesdiy', 'nonuancenovember', 'pleasedontgo', 'amongus', 'imbusyrightnow', 'naturescereal', 'holidaytiktok', 'itwasntaphase', 'winterfashion', 'melaninmagic', 'whereilive', 'laughingduet', 'winterfit', 'groupchat', 'myhobby', '90saesthetic', 'nowlookatthis', 'inlove', 'projectcar', 'relationshipstorytime', 'happyhalloween', 'yougotthis', 'galentinesday', 'welcome2021', 'motivationmonday', 'festivefashion', 'visionboard', 'comfortfood', 'givethanksnotpranks', 'fetapasta', 'horrortok', 'bekind', 'inverted', 'careeradvice', 'growupwithme', 'hellospring', 'feelinggood', 'sabiasque', 'isthisavailable', 'workingathome', 'goodmorning', 'bye2020', 'athletesoftiktok', 'takeabite', 'easydiy', 'watchmegrow', 'holidaydecor', 'seitan', 'myroutine', 'foodontiktok', 'holidaytreats', 'dinnerparty', 'gamergoals', 'tiktokfitness', 'vaccinatedfor', 'wintersports', 'sheearnedit', 'transvisibilityday', 'familyrecipe', 'cozyathome', 'gamingtiktok', 'raisedby', 'thankstoher', 'thinkingabout', 'healthyliving', 'plantparent', 'hereforrmhc', 'oscars', 'valentinesday', 'makeitvogue', 'lifestyle', 'happyholidays', 'lunarnewyear', 'olympicscountdown', 'bakingszn', 'competitivegaming', 'timewarpjump', 'homeproject', 'ourtype', 'cleantok', 'fitnessroutine', 'glasspainting', 'holidayvibes', 'blackcreatives', 'makeblackhistory', 'nativefamily', 'nbadraft', 'lovestory', 'dramaticmoments', 'tortillatrend', 'bakedoats', 'winterbeautytips', 'interiordesign', 'lookbook', 'holidaycountdown', 'ootd', 'selfimprovement', 'albumcover', 'passover', 'homebusiness', 'guitartok', 'tiktoktailgate', 'mycostume', 'science101', 'gamingsetup', 'homeoffice', 'springoutfit', 'rnbvibes', 'autismawareness', 'roundofapplause', 'passingthephone', 'tiktoktutorial', 'thrifting', 'songfacts', 'loveyourinsecurities', 'skincare101']
with open('D:\\Work\\kusuri\\check_missing_p2.csv','w',newline='\n',encoding='utf-8')as fin:
    writer = csv.writer(fin)
    for col in collist:
        print(col)
        t=0
        img=0
        audio=0
        text=0
        for obj in db[col].find():
            t+=1
            for i in range(10):
                if not (len(obj['frame_level']['f'+str(i)]['img']) > 0):
                    img+=1
                if not (type(obj['frame_level']['f'+str(i)]['text']) is str ):
                    text+=1
                if not (len(obj['frame_level']['f'+str(i)]['audio'])>0 ):
                    audio+=1
        writer.writerow([col,t,img,text,audio])
